<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MundiaRegistrar</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript">

$(document).ready(function() {
    $('#monForm').on('submit', function() {
 
        var name = $('#name').val();
 
        if(name == '') {
            alert('il faut remplir le champ name');
        } else {
            $.ajax({
                url: $(this).attr('action'),
                type: $(this).attr('method'),
                data: $(this).serialize(),
                dataType: 'json',
                success: function(json) {
                    if(json.reponse == 'ok') {
                        alert('Tout est bon');
                    } else {
                        alert('Erreur : '+ json.reponse);
                    }
                }
            });
        }
        return false;
    });
    
    $('#filiereForm').on('submit', function() {
    	 
        var id = $('#id_filiere').val();
 		var nom = $('#nom_filiere').val();
        if(id == ''|| nom == '') {
            alert('il faut remplir tout les champs');
        } else {
            $.ajax({
                url: $(this).attr('action'),
                type: $(this).attr('method'),
                data: $(this).serialize(),
                dataType: 'json',
                success: function(json) {
                    if(json.reponse == 'ok') {
                        alert('Tout est bon');
                    } else {
                        alert('Erreur : '+ json.reponse);
                    }
                }
            });
        }
        return false;
    });
});

</script>
</head>
<body>
	<!--  hello!!!!!
	<form id="monForm" action="controleur" method="post">
		<input type="text" name="name" id="name"/>
		<input name="action" value="valider" type="submit"/>
	</form>
	-->
	<form id="filiereForm" action="controleur" method="post">
		id_filiere: <input type="text" name="id_filiere" id="id_filiere"/>
		nom_filiere: <input type="text" name="nom_filiere" id ="nom_filiere"/>
		<input type="submit" value="filiere" name="action"/>
	</form>
	
</body>
</html>